<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkBox extends TemplateGtkGladeWidgetCompilerBase{

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){
		$sWidgetClass=$oObject->getWidgetClass();// GtkHBox, GtkVBox
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sHomogeneous=TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('homogeneous'))?'true':'false';
		$sSpacing=($oObject->getProperty('spacing')===null)?'0':$oObject->getProperty('spacing');
		return
"		{$sVariableName}=new {$sWidgetClass}();
		{$sVariableName}->set_homogeneous({$sHomogeneous});
		{$sVariableName}->set_spacing({$sSpacing});
";
	}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget,TemplateGtkGladeWidgetPacking $oPacking){
		$sParentVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oParentWidget);
		$sChildWidgetVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oChildWidget);
		$sChildWidgetId=$oChildWidget->getWidgetId();
		$sCompiled="\t\t{$sChildWidgetVariableName}=\$this->getWidget('{$sChildWidgetId}',\$arrObjectForSignal);";
		$sExpand=(TemplateGtkGladeObj::nodeTextToValue($oPacking->getProperty('expand'))===false)?'false':'true';
		$sFill=(TemplateGtkGladeObj::nodeTextToValue($oPacking->getProperty('fill'))===false)?'false':'true';
		$sPadding=($sPadding=$oPacking->getProperty('fill'))===null?'0':$sPadding;
		$sPackFunction=$oPacking->getProperty('pack_type')==='GTK_PACK_END'?'pack_end':'pack_start';
		$sCompiled.="\t\t{$sParentVariableName}->{$sPackFunction}({$sChildWidgetVariableName}, {$sExpand}, {$sFill}, {$sPadding});";
		return $sCompiled;
	}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
